package kz.vokebuz.demo;

import kz.vokebuz.demo.db.DbAdapter;
import android.app.Activity;
import android.database.Cursor;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;

public class Main extends Activity {
	/** Called when the activity is first created. */
	public ListView listView;
	private DbAdapter dbAdapter;
	

	public void onCreate(Bundle icicle) {
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		super.onCreate(icicle);
		
		
		setContentView(R.layout.main);
		listView = (ListView) findViewById(R.id.list);
		dbAdapter = new DbAdapter(this);
		dbAdapter.open();
		fillList(dbAdapter.getAllSms());

		
		final Button button = (Button) findViewById(R.id.allsmsbtn);
	 	button.setOnClickListener(new View.OnClickListener() {
           
			
			public void onClick(View v) {

                   //TODO
            }
        });


	}


	private void fillList(Cursor cursor) {
		startManagingCursor(cursor);
		String[] from = new String[] {dbAdapter.COLUMN_SENDER,dbAdapter.COLUMN_TEXT};
		int[] to = new int[]{R.id.rowSender,R.id.rowText};
		SimpleCursorAdapter smsRows = new SimpleCursorAdapter(this,
				R.layout.listrow, cursor, from, to);
		listView.setAdapter(smsRows);
		
	}

}